AddCompany = function(){
	return {
		submitForm : function() {
			if(!$('#companyForm').form('validate')) {
				return;
			}
			var companyCode = $.trim($("#companyCode").val());
			var companyName = $.trim($("#companyName").val());
			$.post('/pc/company/checkCompanyCode.htm', {'companyCode' : companyCode}, function(data) {
				if(data.code == '0') {
					Ict.warn("企业编号已存在,请重新输入!");
				} else if(data.code == '1') {
					$.post('/pc/company/checkCompanyName.htm', {'companyName' : companyName}, function(data) {
						if(data.code == '0') {
							Ict.warn("企业名称已存在,请重新输入!");
						} else if(data.code == '1') {
							AddCompany.saveCompanyInfo();
						} else {
							Ict.warn("未知错误");
						}
					});
				} else {
					Ict.warn("未知错误");
				}
			});
		},
		
		saveCompanyInfo : function() {
			$('#companyForm').form('submit', {
				url      : "/pc/company/addCompany.htm",
				onSubmit : function() {
					return $('#companyForm').form('validate');
				},
				success  : function(data) {
					if(data == "SUCCESS") {
						Ict.info("保存成功!", function() {
							Ict.closeWin2();
							parent.$("iframe").attr('src', "/pc/company/main.htm");
			    		});
					} else {
						Ict.warn("保存失败!");
					}
				}
			});
		}
	};
}();